package com.rd.student.ruanjian.class4.zhouzihe.day17;

import java.io.File;
import java.io.IOException;

public class Test {
    public static void main(String[] args) {
        String projectPath = System.getProperty("user.dir");
        System.out.println(projectPath);
        File dir1 = new File(projectPath + "\\" + "f1");
        dir1.mkdirs();

        File dir2 = new File(projectPath + "\\" + "f2");
        dir2.mkdirs();

        File file1 = new File(dir1.getPath() + "\\" + "t1");
        try {
            file1.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        File file2 = new File(dir1.getPath() + "\\" + "t2");
        try {
            file2.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        File file3 = new File(dir2.getPath() + "\\" + "t3");
        try {
            file3.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        File file4 = new File(dir2.getPath() + "\\" + "t4");
        try {
            file4.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }


        File file5 = new File(projectPath + "\\" + "t3");
        File file6 = new File(projectPath + "\\" + "t4");
        Boolean result = file5.renameTo(file6);
        if (result) {
            System.out.println("变名成功");
        } else {
            System.out.println("失败");
        }
        try {
            file5.createNewFile();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }




        String[] strList = dir1.list();
        for (String s : strList) {
            System.out.println(s);
        }


        String[] strList2 = dir2.list();
        for (String s : strList2) {
            System.out.println(s);
        }

    }
}